package com.edu.exam.enums;

/**
 * 成绩审核操作来源枚举
 *
 * @author System
 * @version 1.0.0 */
public enum GradeAuditOperationSource {
    /** 网页端 */
    WEB("WEB", "网页端"),
    /** 移动端 */
    MOBILE("MOBILE", "移动端"),
    /** API接口 */
    API("API", "API接口"),
    /** 批处理 */
    BATCH("BATCH", "批处理"),
    /** 系统自动 */
    SYSTEM("SYSTEM", "系统自动"),
    /** 第三方系统 */
    THIRD_PARTY("THIRD_PARTY", "第三方系统"),
    /** 数据导入 */
    IMPORT("IMPORT", "数据导入"),
    /** 数据同步 */
    SYNC("SYNC", "数据同步");

    private final String code;
    private final String description;

    GradeAuditOperationSource(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static GradeAuditOperationSource fromCode(String code) {
        if (code == null) {
            throw new IllegalArgumentException("Code cannot be null");
        }
        for (GradeAuditOperationSource source : values()) {
            if (source.getCode().equals(code)) {
                return source;
            }
        }
        throw new IllegalArgumentException("Unknown code: " + code);
    }

    public static GradeAuditOperationSource fromDescription(String description) {
        if (description == null) {
            throw new IllegalArgumentException("Description cannot be null");
        }
        for (GradeAuditOperationSource source : values()) {
            if (source.getDescription().equals(description)) {
                return source;
            }
        }
        throw new IllegalArgumentException("Unknown description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}